package com.ruoyi.web.controller.admin;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.dto.BdmAfterSalesDto;
import com.ruoyi.system.domain.vo.AfterSalesByIdVo;
import com.ruoyi.system.domain.vo.BdmAfterSalesVo;
import com.ruoyi.system.service.IBdmAfterSalesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 售后记录Controller
 * 
 * @author ruoyi
 * @date 2025-01-02
 */
@RestController
@RequestMapping("/admin/sales")
public class BdmAfterSalesController extends BaseController
{
    @Autowired
    private IBdmAfterSalesService bdmAfterSalesService;

    /**
     * 查询售后记录列表
     * @return {@link BdmAfterSalesVo}
     */
    @GetMapping("/queryAfterSalesList")
    public TableDataInfo queryAfterSalesList(BdmAfterSalesDto bdmAfterSalesDto)
    {
        startPage();
        List<BdmAfterSalesVo> list = bdmAfterSalesService.queryAfterSalesList(bdmAfterSalesDto);
        return getDataTable(list);
    }

    /**
     * 查询售后详情
     * @return {@link AfterSalesByIdVo}
     */
    @GetMapping("/queryAfterSalesById")
    public AjaxResult queryAfterSalesById(Long id)
    {
        AfterSalesByIdVo afterSalesByIdVo = bdmAfterSalesService.queryAfterSalesById(id);
        return success(afterSalesByIdVo);
    }

    /**
     * 平台取消退单
     */
    @GetMapping("/cancelRefund")
    public AjaxResult cancelRefund(@NotNull(message = "售后订单号必填") Long id) {
        return toAjax(bdmAfterSalesService.cancelRefund(id));
    }

    /**
     * 平台确认退单
     */
    @PostMapping("/confirmationOfRefund")
    public AjaxResult confirmationOfRefund(@RequestBody List<Long> orderIds) {
        return toAjax(bdmAfterSalesService.confirmationOfRefund(orderIds));
    }

}
